<?php

/*
 * dao.php
 *
 * Gal Gyorgy <skip@inf.elte.hu>
 * 2006. feb. 20., hetfo, 01.52.43 CET
 *
 */

include_once('framework/MySqlDb.php');
include_once('framework/PgSqlDb.php');

class SqlNoSuchProviderException extends SqlException {}

abstract class DataAccessObject
{
    protected $db;
        
    function __construct()
    {
	include('sqlconfig.php');
	
        switch ($dbprovider)
        {
            case 'mysql':
                $this->db = new MySqlDb;
                break;
            
            case 'pgsql':
                $this->db = new PgSqlDb;
                break;

            default:
                throw new SqlNoSuchProviderException($dbprovider);
        }
	
        $this->db->connect($dbhost, $dbport, $dbuser, $dbpass, $dbname);
    }

    function __destruct()
    {
        $this->db->disconnect();
    }
}

?>
